package com.achao.backstagemanage.controller;

import com.achao.basecommon.annotation.ApiMonitorAnnotation;
import com.achao.backstagemanage.service.MusicCollectService;
import com.achao.basecommon.testdomain.User;
import com.achao.basecommon.utils.CustomValidatorUtils;
import com.achao.basecommon.utils.RedisUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 描述：测试
 *
 * @Author：yangchao
 * @CreateDate：2023/1/29 22:22
 */
@RestController
@RequestMapping("/achao/music/after/")
public class AchaoTest {
    private static final Logger logger = LoggerFactory.getLogger(AchaoTest.class);
    @Value("${pattern.dateformat}")
    private String dateformat;

    @Value("${achao.name}")
    private String achaoName;

    @Autowired
    private MusicCollectService musicCollectService;

    @Resource
    private RedisUtils redisUtils;

    /**
     *  描述：测试nacos配置是否能够获取
     */
    @GetMapping("test")
    @ApiMonitorAnnotation(apiModel = "SZFH", apiCode = "QUERY_ALL_UNIT", apiName = "获取业务单位")
    public String sayHello(){
        logger.debug("帅帅气");
        logger.info("帅帅气");
        logger.error("帅帅气");
        System.out.println(achaoName);
        return achaoName + dateformat;
    }

    @GetMapping("redistest")
    public void redisTest(){
        redisUtils.setCacheObject("cache","1");
    }

    //查询所有收藏夹  用于测试feign
    @PostMapping("queryFeignTest")
    public Object queryAllCollect() {
        return musicCollectService.queryAllCollects();
    }

    //参数校验测试类
    @PostMapping("paramsvalid")
    public void paramsValid(){
        User user = new User();
        user.setName("123");
        user.setAge(1102233221);
        /*List<String> list = new ArrayList<>();
        user.setList(list);
        user = null;*/
        logger.info("开始校验");
        CustomValidatorUtils.validate(user);
    }

}
